package day07.ZiXi;

import java.time.LocalDate;
import java.time.Period;

public class Period01 {
    public static void main(String[] args) {
        //public static Period between(开始时间,结束时间)计算两个“时间"的间隔
        LocalDate localDate01 = LocalDate.of(2045,12,24);
        LocalDate localDate02 = LocalDate.of(2089,11,21);
        Period period = Period.between(localDate01,localDate02);
        System.out.println(period);//P43Y10M28D
        //public int getYears()获得这段时间的年数
        System.out.println(period.getYears());//43
        //public int getMonths()获得此期间的总月数
        System.out.println(period.getMonths());//10
        //public int getDays()获得此期间的天数
        System.out.println(period.getDays());//28
        //public long toTotalMonths()获取此期间的总月数
        System.out.println(period.toTotalMonths());//526
    }
}
